﻿<UserControl x:Class="DotBeer.UI.WPFClient.KeyBindingsControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:WindowsInput="clr-namespace:System.Windows.Input;assembly=WindowsBase"
             Height="Auto" 
             Width="Auto">
    <UserControl.Resources>
        <ObjectDataProvider x:Key="keysData"
							MethodName="GetValues"
							ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="WindowsInput:Key"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <ObjectDataProvider x:Key="modifiersKeyData"
							MethodName="GetValues"
							ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="WindowsInput:ModifierKeys"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </UserControl.Resources>
    <Grid>
        <ListBox x:Name="ListBoxBindings"
                 HorizontalAlignment="Stretch"
                 VerticalAlignment="Stretch"
                 Style="{StaticResource ListBoxStyle}"
                 Margin="10,10,10,10">
            <ListBox.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=Name}"
                                       FontWeight="Bold"
                                       Margin="5,5,5,5"/>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListBox.GroupStyle>
            <ListBox.Template>
                <ControlTemplate>
                    <Grid>
                        <Border x:Name="Border" BorderThickness="{DynamicResource ThicknessSize_1}" Background="{DynamicResource BrushControlBackgroundLight}" BorderBrush="{DynamicResource ImpassiveColor4}" CornerRadius="{DynamicResource CornerRadiusSmall}"/>
                        <ScrollViewer Margin="1" Style="{DynamicResource ListBoxScrollViewerStyle}" Focusable="false" Background="{TemplateBinding Background}">
                            <ItemsPresenter />
                        </ScrollViewer>
                    </Grid>
                </ControlTemplate>
            </ListBox.Template>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="10,0,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="150" />
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="100" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="{Binding Path=Description}" 
                                   Grid.Column="0"
                                   Margin="2,2,2,2"/>
                        <ComboBox ItemsSource="{Binding Source={StaticResource keysData}}"
                                  SelectedItem="{Binding Path=Key}"
                                  Style="{StaticResource ComboBoxStyle}"
                                  Grid.Column="1"
                                  Margin="2,2,2,2"/>
                        <ComboBox ItemsSource="{Binding Source={StaticResource modifiersKeyData}}"
                                  SelectedItem="{Binding Path=Modifier}"
                                  Style="{StaticResource ComboBoxStyle}"
                                  Grid.Column="2"
                                  Margin="2,2,2,2"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>